package com.test.baseGroovy

/**
 * Container--GroovyTest
 *
 * @author: Jovi
 *
 * @createTime: 2018-06-12 16:23
 *
 * */

/*====================================List============================================*/
aList = [5, 'String', false]

println aList

println(aList[0].getClass())
println(aList[1].getClass())
println(aList[2].getClass())

println "集合长度"+aList.size()

aList[10] = 100 //给第10个值赋值

aList << 10 //追加数据

println aList

/*====================================Map============================================*/
map = [key1: "value1", key2: "value2", key3: "value3"]
println "$map+数据长度:"+map.size()
println map.keySet()
println map.values()

println("key1的值："+map.key1)
println("key1的值："+map.get("key1"))

map.put("key4", "value4")
Iterator it = map.iterator()
while (it.hasNext()){
    println "遍历："+it.next()
}

println map.containsKey("key1")
println map.containsValue("value1")

Set set = map.keySet()
println set

map.clear()
println(map)

/*========================Range========Range 是 Groovy 对 List 的一种拓展==========*/
range = 1..5
println range
println range.size()
println range.iterator()
s1 = range.get(1)
println s1
println range.contains(5)
println range.last()
println range.class
//range.remove(1)
//range.clear()

range1 = 2..9
println "第一个数据"+range1.from
println "最后一个数据"+range1.to
